import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/Layout.vue'

const routes = [
  {
    path: '/admin',
    name: 'Layout',
    component: () => import('../layout/Layout.vue'),
    redirect: "/user",//当访问/admin时自动访问到user界面里面
    children: [
      //子路由,用来展示表格界面
      {
        path: '/user',
        name: 'user',
        component: () => import('../views/admin/user.vue')
      }, {
        path: '/movie',
        name: 'movie',
        component: () => import('../views/admin/movie.vue')
      }
      , {
        path: '/manager',
        name: 'manager',
        component: () => import('../views/admin/manager.vue')
      }, {
        path: '/bigFilm',
        name: 'bigFilm',
        component: () => import('../views/admin/bigFilm.vue')
      }, {
        //独家
        path: '/only',
        name: 'only',
        component: () => import('../views/admin/only.vue')
      }, {
        //热门
        path: '/hot',
        name: 'hot',
        component: () => import('../views/admin/hot.vue')
      },{
        path: '/log',
        name: 'log',
        component: () => import('../views/admin/log.vue')
      }
    ]
  },
  //网站首页
  {
    path: '/',
    name: 'Index',
    component: () => import('../layout/Index.vue'),
    redirect: "/home",
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('../views/Home.vue')
      },
      {
        path: '/big',
        name: 'big',
        component: () => import('../views/PageBig.vue')
      },
      {
        path: '/hk',
        name: 'hk',
        component: () => import('../views/PageHK.vue')
      },
      {
        path: '/PageOnly',
        name: 'PageOnly',
        component: () => import('../views/PageOnly.vue')
      },
      {
        path: '/Pageinland',
        name: 'Pageinland',
        component: () => import('../views/Pageinland.vue')
      },
      {
        path: '/PageUSA',
        name: 'PageUSA',
        component: () => import('../views/PageUSA.vue')
      },
      {
        path: '/PageHot',
        name: 'PageHot',
        component: () => import('../views/PageHot.vue')
      },
      {
        path: '/player',
        name: 'player',
        component: () => import('../views/player.vue')
      },
      //用户本身的修改界面
      {
        path: '/person',
        name: 'person',
        component: () => import('../views/user/person.vue')
      },
      //搜索之后显示的页面
      {
        path: '/search',
        name: 'search',
        component: () => import('../views/Search.vue')
      },
    ]
  },


  //管理员登录界面
  {
    path: '/adminLogin',
    name: 'adminLogin',
    component: () => import('../views/admin/login.vue')
  },
  //用户登录界面
  {
    path: '/userLogin',
    name: 'userLogin',
    component: () => import('../views/user/login.vue')
  },
  //用户注册界面
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/user/register.vue')
  }

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
